package pers.li.dao;

import pers.li.model.Category;
import pers.li.utils.DataProcess;

import java.util.List;

public class CategoryDao {
    private final DataProcess dataProcess = new DataProcess(true);

    public List<Category> getCategory() {
        String sql = "SELECT *FROM t_category";
        return dataProcess.getObjectList(sql, Category.class);
    }

    public List<Category> getCategoryByParentId(Integer parentId) {
        String sql = "SELECT *FROM t_category where parentid = ?";
        return dataProcess.getObjectList(sql, Category.class, parentId);
    }

    public Category getCategoryByCategoryId(Integer cateId) {
        String sql = "SELECT * FROM t_category WHERE cate_id = ?";
        return dataProcess.getObject(sql, Category.class, cateId);
    }

}
